#!/usr/bin/env python
#coding:utf-8
#This is a guess the number game.
import random

guessesTaken = 0

number = random.randint(1, 20)
while guessesTaken < 6:
    print '猜字小游戏.'
    guess = raw_input('请输入(1-20)中的一个数 ->')
    guess = int(guess)

    guessesTaken += 1

    if guess < number:
        print '%s 太小了.你还有 %s 次机会！' % (guess, 6-guessesTaken)
    elif guess > number:
        print '%s 太大了。你还有 %s 次机会！'% (guess, 6-guessesTaken)
    else:
        break

if guess == number:
    guessesTaken = str(guessesTaken)
    print '你做得不错，正确的数是： %s' % guess
else:
    print '不行呀，下次再努力吧！'
